home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / dbw10s30.zip / DBCREATE.BAS < prev    next >
BASIC Source File  |  1995-04-20  |  1KB  |  51 lines

  1. ' Database Creation Procedures
  2. ' ⌐1995 Tuomas Salste
  3. ' Needs DATACONS.TXT to work
  4. ' Include this module in your project if needed
  5.  
  6. Option Explicit
  7. Global Const DB_COUNTER = -10
  8. Global Const IDX_UNIQUE = True
  9. Global Const IDX_NONUNIQUE = False
  10. Global Const IDX_PRIMARY = True
  11. Global Const IDX_NONPRIMARY = False
  12.  
  13. ' Appends a new field 'FieldName' to a TableDef
  14. Sub AddField (td As TableDef, ByVal FieldName As String, ByVal FieldType As Integer, ByVal Size As Integer)
  15.  
  16. Dim fl As New Field
  17. fl.Name = FieldName
  18. If FieldType = DB_COUNTER Then
  19.     ' If this gives an error, add DATACONS.TXT to your project
  20.     fl.Type = DB_LONG
  21.     fl.Attributes = fl.Attributes Or DB_AUTOINCRFIELD
  22. Else
  23.     fl.Type = FieldType
  24. End If
  25. If FieldType = DB_TEXT Then fl.Size = Size
  26. td.Fields.Append fl
  27.  
  28. End Sub
  29.  
  30. ' Appends a new index 'IndexName' to a TableDef
  31. Sub AddIndex (td As TableDef, ByVal IndexName As String, ByVal IndexFields As String, ByVal IndexPrimary As Integer, ByVal IndexUnique As Integer)
  32.  
  33. Dim idx As New Index
  34. idx.Name = IndexName
  35. idx.Fields = IndexFields
  36. idx.Primary = IndexPrimary
  37. idx.Unique = IndexUnique
  38. td.Indexes.Append idx
  39.  
  40. End Sub
  41.  
  42. ' Appends a QueryDef 'QueryName' to a database
  43. Sub AddQueryDef (db As Database, ByVal QueryName As String, ByVal SQL As String)
  44.  
  45. Dim qd As QueryDef
  46. On Error Resume Next
  47. Set qd = db.CreateQueryDef(QueryName, SQL)
  48.  
  49. End Sub
  50.  
  51.